package cn.itcast.hotel.listener;


import cn.itcast.hotel.constans.MqConstants;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class HotelListener {
    //注入服务对象
    @Autowired
    private IHotelService iHotelService;

    /**
     * 监听新增或修改的消息
     */
    @RabbitListener(queues = MqConstants.HOTEL_INSERT_QUEUE)
    public void listenUpdateOrAdd(Long id) {
        iHotelService.insertHotel(id);
    }

    /**
     * 监听删除
     */
    @RabbitListener(queues = MqConstants.HOTEL_DELETE_QUEUE)
    public void listenDelete(Long id) {
        iHotelService.deleteHotel(id);
    }


}
